import React, { useEffect } from 'react';
import {useState} from 'react'
import { history, IRouteComponentProps ,useModel} from 'umi';
import style from '../index.less'

const Detail: React.FC<IRouteComponentProps> = ():any => {
  let [content,setContent] = useState('')
  let [list,setlist] = useState([])

  let { getinpLists } = useModel('classify', (model: { getinpLists: any; }) => ({ getinpLists: model.getinpLists }));

  async function inp_aa(keyword:string) {
    console.log(content);
    setContent(keyword)
    let res = await getinpLists(keyword)
    console.log(res,'---------------111111111');
    }
 async function  inp_bb() {
    let res = await getinpLists('')
    console.log(res,'---------------111111111');
    setlist(res.data)
  }
  useEffect(() => {
    inp_bb()
  }, [getinpLists]);
  function  th() {
    history.go(-1) 
  }
  return (
    <div className={style.inp_top}>
      <div className={style.a}>
        <span onClick={()=>{th()}}>《</span>
      <input type="text" value={content} onChange={(e)=>inp_aa(e.target.value)}  name="" id=""/>
       <button onClick={()=>inp_aa(content)}>搜索</button>
        </div>  
    <div className={style.b}>
      {
        (list as unknown as any).map((item:any,index:number)=>{
          return (
          <span key={index}>{index}.   {item}</span>
          )
        })
      }
    </div>
    </div>
  );
}
export default Detail